package monitor.tempo.dsa.inpe;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class SplashScreen extends Activity{
	
	protected boolean _active = true;
	protected int _splashTime = 5000;
	protected static int FLAG = 0;
	
	
	
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.splash);
	       
	       
	       
        }
	 @Override
	 public boolean onTouchEvent(MotionEvent event) {
	     if (event.getAction() == MotionEvent.ACTION_DOWN) {
	         _active = false;
	     }
	     return true;
	 }
	 @Override
	protected void onResume() {		
		super.onResume();
		if(FLAG==0){
			// Thread for displaying the SplashScreen
	        Thread splashTread = new Thread() {
	            @Override
	            public void run() {
	                try {
	                    int waited = 0;
	                    while(_active && (waited < _splashTime)) {
	                        sleep(100);
	                        if(_active) {
	                            waited += 100;		                           
	                        }
	                    }
	                } catch(InterruptedException e) {
	                    // do nothing
	                } finally {
	                	finish();
	                    startActivity(new Intent("monitor.tempo.dsa.inpe.MonitorTempoActivity"));	                  
	                }
	            }
	        };
	        
	        splashTread.start();
		}else{
			FLAG = 1;
			finish();	
		}
	}

	
}
